﻿using Lhz.Common.Business;
using Lhz.Sc.Entity.Database;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Lhz.Sc.Business
{
    public class ServiceProxy : EntityProxy<Guid, Service>
    {
        public ServiceProxy(string pathConfiguration = null) : base(pathConfiguration)
        {

        }

        public Service QueryByApplicationNoAndServiceNo(string applicationNo, string serviceNo)
        {
            return CreateQueryable().QueryByApplicationNo(applicationNo).QueryByNo(serviceNo).FirstOrDefault();
        }

        public List<Service> QueryByApplicationGuid(Guid applicationGuid)
        {
            return CreateQueryable().QueryByApplicationGuid(applicationGuid).ToList();
        }

        public bool AnyByApplicationGuid(Guid applicationGuid)
        {
            return CreateQueryable().QueryByApplicationGuid(applicationGuid).Count() > 0;
        }

        public List<Service> QueryByUserGuid(Guid userGuid)
        {
            return CreateQueryable().QueryByUserGuid(userGuid).ToList();
        }
    }
}
